import time
from datetime import datetime
from apscheduler.schedulers.blocking import BlockingScheduler
from sqlalchemy import create_engine, MetaData, Table, select
import redis
import datas


def fetch_and_cache_incremental_data():
    datas.saveTable("album")

# 初始化定时任务调度器
scheduler = BlockingScheduler()

# 每隔10分钟执行一次增量更新
scheduler.add_job(fetch_and_cache_incremental_data, 'interval', minutes=10)

# 启动调度器
try:
    print("Starting scheduler...")
    scheduler.start()
except (KeyboardInterrupt, SystemExit):
    print("Stopping scheduler...")
    scheduler.shutdown()